package com.koro.controller;

import com.koro.dto.FindOrdersDTO;
import com.koro.dto.SaveOrdersDTO;
import com.koro.service.OrdersService;
import com.koro.vo.FindOrdersVO;
import com.koro.vo.ResponseObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "订单管理")
@RestController
@RequestMapping("/orders")
public class OrdersController {

    @Autowired
    private OrdersService ordersService;

    @ApiModelProperty(value = "更新订单",notes = "更新订单")
    @PostMapping("/save")
    public ResponseObject<Integer> save(@RequestBody SaveOrdersDTO dto) {
        return ResponseObject.ok(ordersService.save(dto));
    }

    @ApiModelProperty(value = "查询订单",notes = "查询订单")
    @PostMapping("/findById")
    public ResponseObject<FindOrdersVO> findById(FindOrdersDTO dto) {
        return ResponseObject.ok(ordersService.findById(dto));
    }
}
